// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const _ = db.command
exports.main = async (event, context) => {
  console.log("event111111111111111")
  console.log(event)
  console.log("context22222222222222")
  console.log(context)
  // let userid;
  let openid = event.userInfo.openId;
  let res = await db.collection('user').where({
    openid: _.eq(openid)
  }).update({
    // data 传入需要局部更新的数据
    data: {
      info: event.user
   }
  })
    
  console.log("res33333333333333")
  console.log(res)
  if(res){
    return {
      userInfo: event.user
    }
  }
 
  
}
